package com.runfast.waimai.web.controller.activity;

import com.google.common.base.Joiner;
import com.runfast.common.utils.SessionContext;
import com.runfast.common.web.entity.Result;
import com.runfast.waimai.dao.model.*;
import com.runfast.waimai.service.*;
import com.runfast.waimai.utils.TimeUtil;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cglib.beans.BeanMap;
import org.springframework.data.domain.Pageable;
import org.springframework.data.web.PageableDefault;
import org.springframework.web.bind.annotation.*;

import java.text.ParseException;
import java.util.*;

/**
 * ${DESCRIPTION}活动管理
 *
 * @author chenzheng
 * @create 2018-05-08 21:20
 **/
@RestController("activityController")
@RequestMapping("/server/activity")
public class ActivityController {
    @Autowired
    private RunfastActivityService runfastActivityService;
    @Autowired
    private RunfastBusinessService runfastBusinessService;
    @Autowired
    private RunfastFullLessService runfastFullLessService;
    @Autowired
    private RunfastActivityTargetService runfastActivityTargetService;
    @Autowired
    private WaiMaiRunfastAgentbusinessService waiMaiRunfastAgentbusinessService;
    @Autowired
    private RunfastGoodsSellStandardService runfastGoodsSellStandardService;
    /**
     * 活动列表带分页的
     */
    @GetMapping("/list")
    public Result list(@PageableDefault Pageable pageable, RunfastActivity t) throws ParseException{
        BaseUser admin = SessionContext.getAdmin();
        WaiMaiRunfastAgentaccounts agentAccounts= SessionContext.getCurrentRunfastAgentaccounts();
        RunfastBusinessAccounts accounts = SessionContext.getRunfastBusinessAccounts();
        Map<Object,Object> map=new HashMap<Object, Object>();
        Map<Object,Object> map2=new HashMap<Object, Object>();
        List<RunfastActivity> list=new ArrayList<RunfastActivity>();
        Integer total=null;
        map2.put("pageable",pageable);
        if(t!=null){
            /**活动类型*/
            if(t.getPtype()!=null){
                map2.put("pType",t.getPtype());
            }
            if(StringUtils.isNotBlank(t.getName())){
                map2.put("name",t.getName());
            }
            if(t.getTimeType()!=null){
                map2.put("timeType",t.getTimeType());
            }
            if(t.getCreatetype()!=null){
                map2.put("createtype",t.getCreatetype());
            }
            if(StringUtils.isNotBlank(t.getBusname())){
                map2.put("businessName",t.getBusname());
            }
        }
        if(admin!=null && admin.getType()==3 && accounts!=null){
            //商家帐号登录----只能看自己商家的
        }else if(admin!=null && admin.getType()==2  && agentAccounts!=null){
            //代理商
            map2.put("agentIds",agentAccounts.getAgentid());
        }else if(admin !=null  && admin.getType()==1){
            //后台管理员---查看全部的
            if(StringUtils.isNotBlank(t.getAgentIds())){
                map2.put("agentIds",t.getAgentIds());
            }
        }
        list=runfastActivityService.selectByMapWithPageable(map2);
        total=runfastActivityService.countByMap(map2);
        if(list.size()>0){
            for(RunfastActivity activity:list){
                setActivity1(activity);
                if(activity. getPtype()==1){
                    //满减的时候，联合满减表查询出活动的满减信息
                    RunfastFullLessExample fullLessExample=new RunfastFullLessExample();
                    fullLessExample.createCriteria().andActivityIdEqualTo(activity.getId());
                    List<RunfastFullLess> fullLessList=runfastFullLessService.selectByExample(fullLessExample);
                    activity.setRunfastFullLess(fullLessList);
                }
                if(activity.getPtype()==2||activity.getPtype()==4){
                    //特价或者打折
                    RunfastActivityTargetExample targetExample=new RunfastActivityTargetExample();
                    targetExample.createCriteria().andActivityidEqualTo(activity.getId());
                    List<RunfastActivityTarget> targetList=runfastActivityTargetService.selectByExample(targetExample);
                    /**某一个活动参加商户名字及该商户参加的商品个数*/
                    List<Map<Object,Object>>  mapList1=new ArrayList<Map<Object,Object>>();
                    if(targetList!=null){
                        for(RunfastActivityTarget  target:targetList){
                            RunfastBusiness  business=runfastBusinessService.selectByPrimaryKey(target.getBusinessid());
                            RunfastActivityTargetExample targetExample1=new RunfastActivityTargetExample();
                            targetExample1.createCriteria().andActivityidEqualTo(activity.getId()).andBusinessidEqualTo(business.getId());
                            //targetExample1.createCriteria().andBusinessidEqualTo(business.getId());
                            Integer num1=runfastActivityTargetService.countByExample(targetExample1);
                            Map<Object,Object> map1=new HashMap<Object, Object>();
                            map1.put("businessName",business.getName());
                            map1.put("goodsNum",num1);
                            mapList1.add(map1);
                        }
                    }
                    activity.setMapList(mapList1);
                }else if(activity.getPtype()!=2&&activity.getPtype()!=4){
                    List<Integer> alist=new ArrayList<Integer>();
                    if(activity.getAgentid()!=null){
                        WaiMaiRunfastAgentbusiness agentbusiness=waiMaiRunfastAgentbusinessService.selectByPrimaryKey(activity.getAgentid());
                        if(agentbusiness!=null){
                            Map<Object,Object> map3=new HashMap<Object, Object>();
                            map3.put("agengtIds",agentbusiness.getId());
                            map3.put("activityId",activity.getId());
                            Integer num=runfastActivityTargetService.countByMap(map3);
                            activity.setBusinessNum(num);
                        }else{return Result.fail(null,"找不到对应的代理商！");}
                    }
                }
            }
        }
        map.put("list",list);
        map.put("total",total);
        return Result.ok(null,map);
    }


    /**
     * 优惠专区---活动列表带分页的
     */
    @GetMapping("/specialPriceAreaList")
    public Result specialPriceAreaList(@PageableDefault Pageable pageable, RunfastActivity activity){
         List<RunfastActivity> list=new ArrayList<RunfastActivity>();
         Integer total =null;
        Map<Object,Object> map=new HashMap<Object, Object>();
        if(StringUtils.isNotBlank(activity.getName())){
            map.put("name",activity.getName());
        }
         if(activity!=null && activity.getSelectNum()!=null){
             BaseUser admin = SessionContext.getAdmin();
             WaiMaiRunfastAgentaccounts agentAccounts= SessionContext.getCurrentRunfastAgentaccounts();
             RunfastBusinessAccounts accounts = SessionContext.getRunfastBusinessAccounts();
             map.put("pageable",pageable);
             if(admin!=null && admin.getType()==3 && accounts!=null && accounts.getBusinessid()!=null){
                 //商家帐号登录----只能看自己商家的
                 if(accounts.getBusinessid()!=null){
                     RunfastBusiness business=runfastBusinessService.selectByPrimaryKey(accounts.getBusinessid());
                     if(business!=null){
                         map.put("businessId",business.getId());
                     }else{return Result.fail(null,"找不到对应的商家！");}
                 }
             }else if(admin!=null && admin.getType()==2  && agentAccounts!=null && agentAccounts.getAgentid()!=null){
                 //代理商
                 if(agentAccounts.getAgentid()!=null){
                     WaiMaiRunfastAgentbusiness agentbusiness=waiMaiRunfastAgentbusinessService.selectByPrimaryKey(agentAccounts.getAgentid());
                     if(agentbusiness!=null){
                         map.put("agentId",agentbusiness.getId());
                     }else{return Result.fail(null,"找不到对应的代理商！");}
                 }
             }else if(admin !=null  && admin.getType()==1 && admin.getId()!=null){
                 if(activity.getAgentid()!=null){
                     WaiMaiRunfastAgentbusiness agentbusiness=waiMaiRunfastAgentbusinessService.selectByPrimaryKey(activity.getAgentid());
                     if(agentbusiness!=null){
                         map.put("agentId",agentbusiness.getId());
                     }else{return Result.fail(null,"未找到对应的代理商！");}
                 }else{
                     //后台管理员---查看全部的
                     List<WaiMaiRunfastAgentbusiness> agentbusinessList=waiMaiRunfastAgentbusinessService.selectByExample(null);
                     if(agentbusinessList.size()>0){
                         map.put("agentId",agentbusinessList.get(0).getId());
                     }
                 }
             }else{return Result.fail(null,"未登录！");}
             if(activity.getSelectNum()==1){
                 //优惠专区/大额满减活动
                 map.put("pType",1);
             }else if(activity.getSelectNum()==2){
                 //满配送费活动
                 map.put("pTypes","5,7");
             }else if(activity.getSelectNum()==3){
                 //特惠优选专区--单品活动
                 map.put("pTypes","2,4");
             }
             list=runfastActivityService.selectByExampleNew(map);
             if(list.size()>0){
                for(RunfastActivity activity1:list){
                    if(activity1. getPtype()==1){
                        //满减的时候，联合满减表查询出活动的满减信息
                        RunfastFullLessExample fullLessExample=new RunfastFullLessExample();
                        fullLessExample.createCriteria().andActivityIdEqualTo(activity1.getId());
                        List<RunfastFullLess> fullLessList=runfastFullLessService.selectByExample(fullLessExample);
                        activity1.setRunfastFullLess(fullLessList);
                    }
                    if(activity1.getSpecialType()!=null && activity1.getSpecialType()==1){
                        activity1.setSpecialType1(true);
                    }else{ activity1.setSpecialType1(false);}
                }
             }
             total =runfastActivityService.countByExampleNew(map);
         }else{return Result.fail(null,"传入参数不对！");}
        Map<Object,Object> map1=new HashMap<Object, Object>();
         map1.put("list",list);
         map1.put("total",total);
        return Result.ok(null,map1);
    }



    /**
     * 保存活动
     */
    @PostMapping("/save")
    public Result save(@RequestBody RunfastActivity activity) throws ParseException {
        BaseUser admin = SessionContext.getAdmin();
        WaiMaiRunfastAgentaccounts agentAccounts= SessionContext.getCurrentRunfastAgentaccounts();
        RunfastBusinessAccounts accounts = SessionContext.getRunfastBusinessAccounts();
        if(activity!=null && StringUtils.isNotBlank(activity.getName()) && StringUtils.isNotBlank(activity.getStartTimeToendTime())){
            if(activity!=null && activity.getPtype()!=null){
                if(admin!=null && admin.getType()==3 && accounts!=null){
                    //商家登录
                    activity.setCreateby(accounts.getId());
                    activity.setCreatetype(0);
                }else if(admin!=null  && admin.getType()==2 && agentAccounts!=null){
                    //代理商登录
                    activity.setCreateby(agentAccounts.getAgentid());
                    activity.setCreatetype(1);
                }else if(admin!=null &&admin.getType()==1){
                    // 后台用户登录
                    activity.setCreateby(admin.getId());
                    activity.setCreatetype(2);
                }
                activity.setStops(0);
                activity.setCreatetime(new Date());
                activity.setDeleted(0);
                activity.setDiscard(false);
                setActivity(activity);
                if(activity.getPtype()==2||activity.getPtype()==4){
                    if(activity.getShared()!=null  && activity.getIsLimited()!=null && activity.getWorktoday().size()>0){
                        //特价或者打折--针对一个商家的商品
                        if(activity.getIsLimited()==null||activity.getIsLimited()==true){
                            activity.setIsLimited(true);
                        }
                        if(activity.getBusid()!=null){
                            RunfastBusiness business = runfastBusinessService.selectByPrimaryKey(activity.getBusid());
                            if(business!=null){
                                WaiMaiRunfastAgentbusiness  agentbusiness =waiMaiRunfastAgentbusinessService.setAgent(business.getAgentid());
                                //WaiMaiRunfastAgentbusiness  agentbusiness =setAgent(business.getAgentid());
                                if(agentbusiness!=null){
                                    activity.setAgentname(agentbusiness.getName());
                                    activity.setAgentid(agentbusiness.getId());
                                }else{return Result.fail(null,"找不到对应的代理商！");}
                                runfastActivityService.insertSelective(activity);
                            }
                        }
                    }else{return Result.fail(null,"传入参数不对！");}
                } else if(activity.getPtype()==1){
                    if(activity.getAgentid()!=null && StringUtils.isNotBlank(activity.getSpecialImg()) && activity.getRunfastFullLess().size()>0 && activity.getShared()!=null &&activity.getWorktoday().size()>0 ){
                        //WaiMaiRunfastAgentbusiness  agentbusiness =setAgent(activity.getAgentid());
                        WaiMaiRunfastAgentbusiness  agentbusiness =waiMaiRunfastAgentbusinessService.setAgent(activity.getAgentid());
                        if(agentbusiness!=null){
                            activity.setAgentname(agentbusiness.getName());
                            activity.setAgentid(agentbusiness.getId());
                        }else{return Result.fail(null,"找不到对应的代理商！");}
                        //满减
                        runfastActivityService.insertSelective(activity);
                        if(activity.getRunfastFullLess().size()>0){
                            for(RunfastFullLess fullLess:activity.getRunfastFullLess()){
                                fullLess.setActivityId(activity.getId());
                                runfastFullLessService.insertSelective(fullLess);
                            }
                        }
                    }else{return Result.fail(null,"传入参数不对！");}
                }else if(activity.getPtype()==5||activity.getPtype()==7){
                    if(activity.getAgentid()!=null && StringUtils.isNotBlank(activity.getSpecialImg())){
                        //WaiMaiRunfastAgentbusiness  agentbusiness =setAgent(activity.getAgentid());
                        WaiMaiRunfastAgentbusiness  agentbusiness =waiMaiRunfastAgentbusinessService.setAgent(activity.getAgentid());
                        if(agentbusiness!=null){
                            activity.setAgentname(agentbusiness.getName());
                            activity.setAgentid(agentbusiness.getId());
                        }else{return Result.fail(null,"找不到对应的代理商！");}
                        //免运费，免部分运费,满免运费
                        if(activity.getPtype()==5){
                            //满免运费
                            if(activity.getFulls()!=null&&activity.getAgentSubsidy()!=null){
                                runfastActivityService.insertSelective(activity);
                            }else{return Result.fail(null,"传入参数不对！");}
                        }else if(activity.getPtype()==7){
                            //免部分运费
                            if(activity.getLesss()!=null && activity.getAgentSubsidy()!=null){
                                if(activity.getAgentSubsidy()>activity.getLesss()){
                                    return  Result.fail(null,"代理商补贴金额不能大于减免的金额！");
                                }
                                runfastActivityService.insertSelective(activity);
                            }else{return Result.fail(null,"传入参数不对！");}
                        }
                    }else{return Result.fail(null,"传入参数不对！");}
                }else if(activity.getPtype()==8){
                    //新用户立减活动
                    if(activity.getAgentid()!=null && activity.getLesss()!=null && activity.getAgentSubsidy()!=null){
                        //WaiMaiRunfastAgentbusiness  agentbusiness =setAgent(activity.getAgentid());
                        WaiMaiRunfastAgentbusiness  agentbusiness =waiMaiRunfastAgentbusinessService.setAgent(activity.getAgentid());
                        if(agentbusiness!=null){
                            activity.setAgentname(agentbusiness.getName());
                            activity.setAgentid(agentbusiness.getId());
                        }else{return Result.fail(null,"找不到对应的代理商！");}
                        if(activity.getAgentSubsidy()>activity.getLesss()){
                            return  Result.fail(null,"代理商补贴金额不能大于减免的金额！");
                        }
                        runfastActivityService.insertSelective(activity);
                    }else{return Result.fail(null,"传入参数不对！");}
                }else if(activity.getPtype()==10){
                    //商家红包
                    if(activity.getBusid()!=null && activity.getRedlimittype()!=null && activity.getRednum()!=null && activity.getRedpersonlimittype()!=null &&StringUtils.isNotBlank(activity.getRedamount()) && activity.getFulls()!=null &&activity.getShared()!=null){
                        RunfastBusiness business = runfastBusinessService.selectByPrimaryKey(activity.getBusid());
                        if(business!=null){
                            activity.setBusid(business.getId());
                            activity.setBusname(business.getName());
                            //WaiMaiRunfastAgentbusiness  agentbusiness =setAgent(business.getAgentid());
                            WaiMaiRunfastAgentbusiness  agentbusiness =waiMaiRunfastAgentbusinessService.setAgent(activity.getAgentid());
                            if(agentbusiness!=null){
                                activity.setAgentname(agentbusiness.getName());
                                activity.setAgentid(agentbusiness.getId());
                            }else{return Result.fail(null,"找不到对应的代理商！");}
                            runfastActivityService.insertSelective(activity);
                            RunfastActivityTarget target=new RunfastActivityTarget();
                            target.setActivityid(activity.getId());
                            target.setBusinessid(business.getId());
                            target.setStops(0);
                            target.setAgentid(agentbusiness.getId());
                            runfastActivityTargetService.insert(target);
                        }else{return Result.fail(null,"找不到对应的商家！");}
                    }else{return Result.fail(null,"传入参数不对！");}
                }else if(activity.getPtype()==11){
                    //下单返红包
                    if(activity.getBusid()!=null &&activity.getFulls()!=null&& activity.getShared()!=null &&  activity.getRedamount()!=null && activity.getRedlimittype()!=null && activity.getRednum()!=null && activity.getRedpersonlimittype()!=null){
                        RunfastBusiness business = runfastBusinessService.selectByPrimaryKey(activity.getBusid());
                        if(business!=null){
                            activity.setBusid(business.getId());
                            activity.setBusname(business.getName());
                            //WaiMaiRunfastAgentbusiness  agentbusiness =setAgent(business.getAgentid());
                            WaiMaiRunfastAgentbusiness  agentbusiness =waiMaiRunfastAgentbusinessService.setAgent(business.getAgentid());
                            if(agentbusiness!=null){
                                activity.setAgentname(agentbusiness.getName());
                                activity.setAgentid(agentbusiness.getId());
                            }else{return Result.fail(null,"找不到对应的代理商！");}
                            runfastActivityService.insertSelective(activity);
                            RunfastActivityTarget target=new RunfastActivityTarget();
                            target.setActivityid(activity.getId());
                            target.setBusinessid(business.getId());
                            target.setStops(0);
                            target.setAgentid(agentbusiness.getId());
                            runfastActivityTargetService.insert(target);
                        }else{return Result.fail(null,"找不到对应的商家！");}
                    }else{return Result.fail(null,"传入参数不对！");}
                }else if(activity.getPtype()==12){
                    //代理商发红包
                    if(activity.getAgentid()!=null  &&activity.getFulls()!=null && activity.getShared()!=null && activity.getRedamount()!=null && activity.getRedlimittype()!=null && activity.getRednum()!=null && activity.getRedpersonlimittype()!=null && activity.getRedusertype()!=null){
                        WaiMaiRunfastAgentbusiness agentbusiness=waiMaiRunfastAgentbusinessService.selectByPrimaryKey(activity.getAgentid());
                        if(agentbusiness!=null){
                            activity.setAgentid(agentbusiness.getId());
                            activity.setAgentname(agentbusiness.getName());
                            runfastActivityService.insertSelective(activity);
                            RunfastActivityTarget target=new RunfastActivityTarget();
                            target.setActivityid(activity.getId());
                            target.setStops(0);
                            target.setAgentid(agentbusiness.getId());
                            runfastActivityTargetService.insert(target);
                        }else{return Result.fail(null,"找不到对应的代理商！");}
                    }else{return Result.fail(null,"传入参数不对！");}
                }
            }else{return Result.fail(null,"活动类型不能为空！");}
        }else{return Result.fail(null,"传入参数不对！");}
        Map<Object,Object> map=new HashMap<Object, Object>();
        map.put("activityId",activity.getId());
        return Result.ok(null,map);
    }


    /**前端传给后台数据转换--营业时间*/
    public void setActivity(RunfastActivity activity)  throws ParseException{
        if(StringUtils.isNotBlank(activity.getStartTimeToendTime())){
            List<String> result = Arrays.asList(StringUtils.split(activity.getStartTimeToendTime(),","));
            if(result.size()>0){
                activity.setStarttime(TimeUtil.getDate(result.get(0)));
                activity.setEndtime(TimeUtil.getDate(result.get(1)));
            }
        }else{
            activity.setStarttime(null);
            activity.setEndtime(null);
        }
        if(StringUtils.isNotBlank(activity.getFirstTime())){
            List<String> result = Arrays.asList(StringUtils.split(activity.getFirstTime(),","));
            if(result.size()>0){
                activity.setStart1(TimeUtil.getHourAndMinute(result.get(0)));
                activity.setEnd1(TimeUtil.getHourAndMinute(result.get(1)));
            }
        }else{
            activity.setStart1(null);
            activity.setEnd1(null);
        }
        if(StringUtils.isNotBlank(activity.getSecondTime())){
            List<String> result = Arrays.asList(StringUtils.split(activity.getSecondTime(),","));
            if(result.size()>0){
                activity.setStart2(TimeUtil.getHourAndMinute(result.get(0)));
                activity.setEnd2(TimeUtil.getHourAndMinute(result.get(1)));
            }
        }else{
            activity.setStart2(null);
            activity.setEnd2(null);
        }
        if(StringUtils.isNotBlank(activity.getThirdTime())){
            List<String> result = Arrays.asList(StringUtils.split(activity.getThirdTime(),","));
            if(result.size()>0){
                activity.setStart3(TimeUtil.getHourAndMinute(result.get(0)));
                activity.setEnd3(TimeUtil.getHourAndMinute(result.get(1)));
            }
        }else{
            activity.setStart3(null);
            activity.setEnd3(null);
        }
        if(activity.getWorktoday().size()>0){
            activity.setWeek(Joiner.on(",").join(activity.getWorktoday()));
        }
    }


    /**后台传给前台数据转换*/
    public void setActivity1(RunfastActivity activity)  throws ParseException{
        if(activity.getStarttime()!=null && activity.getEndtime()!=null){
            activity.setStartTimeToendTime(TimeUtil.getDateToString(activity.getStarttime())+","+TimeUtil.getDateToString(activity.getEndtime()));
        }
        if(activity.getStart1()!=null && activity.getEnd1()!=null){
            activity.setFirstTime(TimeUtil.getHourAndMinuteToString(activity.getStart1())+","+TimeUtil.getHourAndMinuteToString(activity.getEnd1()));
        }
        if(activity.getStart2()!=null && activity.getEnd2()!=null){
            activity.setSecondTime(TimeUtil.getHourAndMinuteToString(activity.getStart2())+","+TimeUtil.getHourAndMinuteToString(activity.getEnd2()));
        }
        if(activity.getStart3()!=null && activity.getEnd3()!=null){
            activity.setThirdTime(TimeUtil.getHourAndMinuteToString(activity.getStart3())+","+TimeUtil.getHourAndMinuteToString(activity.getEnd3()));
        }
        if(StringUtils.isNotBlank(activity.getWeek())){
            List<String> result = Arrays.asList(StringUtils.split(activity.getWeek(),","));
            activity.setWorktoday(result);
        }
    }
    /**活动详情*/
    @GetMapping("/info")
    public Result info(Integer activityId) throws ParseException{
        if(activityId==null){return Result.fail(null,"没有活动id！");}
        RunfastActivity activity=runfastActivityService.selectByPrimaryKey(activityId);
        if(activity!=null){
            if(activity.getAgentid()!=null){
                WaiMaiRunfastAgentbusiness  agentbusiness=waiMaiRunfastAgentbusinessService.selectByPrimaryKey(activity.getAgentid());
                if(agentbusiness!=null){
                    activity.setAgentname(agentbusiness.getName());
                }
            }
            setActivity1(activity);
            if(activity.getPtype()==1){
                    //满减活动
                    RunfastFullLessExample example=new RunfastFullLessExample();
                    example.createCriteria().andActivityIdEqualTo(activity.getId());
                    List<RunfastFullLess> list=runfastFullLessService.selectByExample(example);
                    activity.setRunfastFullLess(list);
            }else if(activity.getPtype()==2){

            }
        }else{return Result.fail(null,"找不到对应的活动！");}
        return Result.ok(null,activity);
    }

    /**
     * 满减活动,配送费活动，新用户活动---保存去选门店信息
     * */
    @GetMapping("/selectActivityBusiness")
    public Result selectActivityBusiness(Integer activityId,@PageableDefault Pageable pageable,Integer selectType,Integer businessId,String name){
        if(activityId==null){return  Result.fail(null,"没有活动id！");}
        RunfastActivity activity=runfastActivityService.selectByPrimaryKey(activityId);
        Integer total=0;
        List<Map<?,?>> beans = new ArrayList<>();
        if(activity!=null){
            if(activity.getAgentid()!=null){
                if(selectType!=null){
                      //1--全部 2:已上线   3：未上线
                   if(selectType!=2 && selectType != 3){
                       selectType = null;
                   }
                }
                List<RunfastBusiness> businessList=runfastBusinessService.getAcivityBusinessByExampleWithPageable(activity.getAgentid(), activityId, selectType, businessId, name,pageable);
                if(businessList.size()>0){
                    String ptype = null;
                    if(activity.getPtype()!=null && (activity.getPtype()==5 || activity.getPtype()==7)){
                        //免配送费活动（两种）
                        ptype = "5,7";
                    }else{
                        ptype = String.valueOf(activity.getPtype());
                    }
                    for(RunfastBusiness business:businessList){
                        Map<String,String> onlineResult = runfastBusinessService.getOnlineActivity(activity.getAgentid(), ptype, activity.getId(), business.getId());
                        //设置是否在活动
                        business.setIsOnline("true".equalsIgnoreCase(onlineResult.get("isOnline")));
                        //转为Map
                        BeanMap bean = BeanMap.create(business);
                        Map<Object,Object> map = new HashMap<>();
                        map.putAll(bean);
                        // 别的同类型活动在线
                        map.put("isOtherSimilarOnline","true".equalsIgnoreCase(onlineResult.get("isOtherOnline")));
                        beans.add(map);
                    }
                }
                total=runfastBusinessService.countAcivityBusinessByExampleWithPageable(activity.getAgentid(), activityId, selectType, businessId, name,pageable);
            }
        }else{return Result.fail(null,"找不到对应的活动！");}
        Map<Object,Object> map=new HashMap<Object, Object>();
        map.put("total",total);
        map.put("businessList",beans);
        return Result.ok(null,map);
    }

    /**选择商家*/
    @GetMapping("/selectBusiness")
    public Result selectBusiness(@PageableDefault Pageable pageable,String name,Integer agentid){
        BaseUser admin = SessionContext.getAdmin();
        WaiMaiRunfastAgentaccounts agentAccounts= SessionContext.getCurrentRunfastAgentaccounts();
        RunfastBusinessAccounts accounts = SessionContext.getRunfastBusinessAccounts();
        RunfastBusinessExample example=new RunfastBusinessExample();
        RunfastBusinessExample.Criteria exampleCriteria=example.createCriteria();
        exampleCriteria.andStatusxNotEqualTo(-1).andStatusEqualTo(0);
        if(StringUtils.isNotBlank(name)){
            exampleCriteria.andNameLike("%"+name+"%");
        }
        if(agentid!=null){
            exampleCriteria.andAgentidEqualTo(agentid);
        }
        if(admin!=null && admin.getType()==1){
            //所有商家
        }else if(admin!=null && admin.getType()==2 && agentAccounts!=null){
            //代理商
            exampleCriteria.andAgentidEqualTo(agentAccounts.getAgentid());
        }else if(admin!=null && admin.getType()==3 && accounts!=null){
            //商家
            exampleCriteria.andIdEqualTo(accounts.getBusinessid());
        }
         List<RunfastBusiness> list=runfastBusinessService.selectByExampleWithPageable(example,pageable);
        if(list.size()>0){
             for(RunfastBusiness business:list){
                   if(business!=null && business.getAgentid()!=null){
                           WaiMaiRunfastAgentbusiness  agentbusiness=waiMaiRunfastAgentbusinessService.selectByPrimaryKey(business.getAgentid());
                           if(agentbusiness!=null){
                               business.setAgentname(agentbusiness.getName());
                           }
                   }
             }
        }
         Integer total=runfastBusinessService.countByExample(example);
        Map<Object,Object> map=new HashMap<Object, Object>();
        map.put("total",total);
        map.put("list",list);
     return Result.ok(null,map);
    }




     /**单个商家上线,下线*/
     @PostMapping("/setActivityToBusiness")
     public Result setActivityToBusiness(@RequestBody RunfastBusiness business){
        if(business!=null){
            if(business.getId()!=null && business.getActivityId()!=null && business.getIsOnline()!=null){
                RunfastBusiness business1=runfastBusinessService.selectByPrimaryKey(business.getId());
                RunfastActivity activity = runfastActivityService.selectByPrimaryKey(business.getActivityId());
                if(business1!=null && activity!=null){
                    if(business.getIsOnline()==true){
                        //上线
                        Map<Object,Object> map2=new HashMap<Object, Object>();
                        map2.put("agentId",activity.getAgentid());
                        if(activity.getPtype()!=null && (activity.getPtype()==5 || activity.getPtype()==7)){
                            //免配送费活动（两种）
                            map2.put("ptypes","5,7");
                        }else{
                            map2.put("ptype",activity.getPtype());
                        }
                        map2.put("businessId",business1.getId());
                        Integer t=runfastBusinessService.countAcivityByExample(map2);
                        if(t>0){
                             return Result.fail(null,"该商家已经有同类型的活动，不能上线该活动！");
                        }else{
                            RunfastActivityTarget target=new RunfastActivityTarget();
                            target.setActivityid(activity.getId());
                            target.setAgentid(activity.getAgentid());
                            target.setStops(0);
                            target.setBusinessid(business1.getId());
                            runfastActivityTargetService.insert(target);
                        }
                    }else if(business.getIsOnline()==false){
                        //下线
                        Map<Object,Object> map2=new HashMap<Object, Object>();
                        map2.put("agentId",activity.getAgentid());
                        map2.put("ptype",activity.getPtype());
                        //map2.put("selectType",2);
                        //map2.put("activityId",activity.getId());
                        map2.put("businessId",business1.getId());
                        Integer t=runfastBusinessService.countAcivityByExample(map2);
                        if(t>0){
                           //有活动，可以下线
                            RunfastActivityTargetExample example=new RunfastActivityTargetExample();
                            example.createCriteria().andActivityidEqualTo(activity.getId()).andBusinessidEqualTo(business1.getId());
                            List<RunfastActivityTarget> targetList=runfastActivityTargetService.selectByExample(example);
                            if(targetList.size()>0){
                                for(RunfastActivityTarget target:targetList){
                                    //下线---暂停
                                    target.setDeleted(true);
                                    runfastActivityTargetService.updateByPrimaryKeySelective(target);
                                }
                            }
                        }else{return Result.fail(null,"该商家未参加次活动，无法下线！");}
                    }
                }else{return Result.fail(null,"未找到对应的商家或者活动！");}
            }else{return Result.fail(null,"传入的参数不对！");}
        }else{return Result.fail(null,"没有传入的参数！");}
        return Result.ok(null);
     }

     /**批量商家上线，下线*/
     @PostMapping("/setActivityToBusinesss")
     public Result setActivityToBusinesss(@RequestBody RunfastBusiness business){
         if(business!=null){
             if(business.getIds().size()>0 && business.getActivityId()!=null && business.getIsOnline()!=null) {
                 for (Integer id : business.getIds()) {
                     RunfastBusiness business1 = runfastBusinessService.selectByPrimaryKey(id);
                     RunfastActivity activity = runfastActivityService.selectByPrimaryKey(business.getActivityId());
                     if (business1 != null && activity != null) {
                         if (business.getIsOnline() == true) {
                             //上线
                             Map<Object, Object> map2 = new HashMap<Object, Object>();
                             map2.put("agentId", activity.getAgentid());
                             map2.put("ptype", activity.getPtype());
                             map2.put("businessId", business1.getId());
                             Integer t = runfastBusinessService.countAcivityByExample(map2);
                             if (t > 0) {
                                 //return Result.fail(null, "该商家已经有同类型的活动，不能上线该活动！");
                             } else {
                                 RunfastActivityTarget target = new RunfastActivityTarget();
                                 target.setActivityid(activity.getId());
                                 target.setAgentid(activity.getAgentid());
                                 target.setStops(0);
                                 target.setBusinessid(business1.getId());
                                 runfastActivityTargetService.insert(target);
                             }
                         } else if (business.getIsOnline() == false) {
                             //下线
                             Map<Object, Object> map2 = new HashMap<Object, Object>();
                             map2.put("agentId", activity.getAgentid());
                             map2.put("ptype", activity.getPtype());
                             map2.put("businessId", business1.getId());
                             Integer t = runfastBusinessService.countAcivityByExample(map2);
                             if (t > 0) {
                                 //有活动，可以下线
                                 RunfastActivityTargetExample example = new RunfastActivityTargetExample();
                                 example.createCriteria().andActivityidEqualTo(activity.getId()).andBusinessidEqualTo(business1.getId()).andAgentidEqualTo(business1.getAgentid());
                                 List<RunfastActivityTarget> targetList = runfastActivityTargetService.selectByExample(example);
                                 if (targetList.size() > 0) {
                                     for(RunfastActivityTarget target:targetList){
                                         //下线---暂停
                                         target.setDeleted(true);
                                         runfastActivityTargetService.updateByPrimaryKeySelective(target);
                                     }
                                 }
                             } else {
                                 //return Result.fail(null, "该商家未参加次活动，无法下线！");
                             }
                         }
                     } else {
                         return Result.fail(null, "未找到对应的商家或者活动！");
                     }
                 }
             }else{return Result.fail(null,"传入的参数不对！");}
         }else{return Result.fail(null,"没有传入的参数！");}
         return Result.ok(null);
     }
     /**保存折扣及特价*/
     @PostMapping("/saveStandardActivity")
     public Result  saveStandardActivity(@RequestBody RunfastActivityTarget target){
         if(target!=null && target.getActivityid()!=null && target.getStandarid()!=null &&(target.getDiscount()!=null ||target.getDisprice()!=null)){
             RunfastActivity activity = runfastActivityService.selectByPrimaryKey(target.getActivityid());
             RunfastGoodsSellStandard standard=runfastGoodsSellStandardService.selectByPrimaryKey(target.getStandarid());
             Map<Object, Object> map= new HashMap<Object, Object>();
             map.put("standardId",standard.getId());
             map.put("agengtIds",activity.getAgentid());
             map.put("businessId",activity.getBusid());
             map.put("goodsId",standard.getGoodssellid());
             Integer total=runfastActivityTargetService.countByMap(map);
             if(total>0){
                 //return Result.fail(null,"该商品的此规格已经参加了单品活动！");
                 List<RunfastActivityTarget>   activityTargetList=runfastActivityTargetService.selectTargetAndActivityByMap(map);
                 if(activityTargetList.size()>0){
                     if(activity!=null && standard!=null){
                         RunfastActivityTarget target1=activityTargetList.get(0);
                         RunfastActivity activity1 = runfastActivityService.selectByPrimaryKey(target1.getActivityid());
                         if(activity1.getPtype().equals(activity.getPtype())){
                             if(target.getDiscount()==null && target.getDisprice()!=null){
                                 //特价
                                 target1.setStops(0);
                                 target1.setBusinessid(activity.getBusid());
                                 target1.setActivityid(activity.getId());
                                 target1.setAgentid(activity.getAgentid());
                                 target1.setDisprice(target.getDisprice());
                                 target1.setStandarid(standard.getId());
                                 target1.setGoodsid(standard.getGoodssellid());
                                 runfastActivityTargetService.updateByPrimaryKeySelective(target1);
                             }else if(target.getDiscount()!=null){
                                 //折扣
                                 Double i=0.00;
                                 i=standard.getPrice()*target.getDiscount();
                                 target1.setStops(0);
                                 target1.setBusinessid(activity.getBusid());
                                 target1.setActivityid(activity.getId());
                                 target1.setAgentid(activity.getAgentid());
                                 if(target.getDisprice()!=null){
                                     target1.setDisprice(target.getDisprice());
                                 }else{ target1.setDisprice(i);}
                                 target1.setDiscount(target.getDiscount());
                                 target1.setStandarid(standard.getId());
                                 target1.setGoodsid(standard.getGoodssellid());
                                 runfastActivityTargetService.updateByPrimaryKeySelective(target1);
                             }
                         }else{return Result.fail(null,"只能修改为同类型的活动！");}
                     }else{return Result.fail(null,"找不到对应的活动或者规格！");}
                 }
             }else{
                 if(activity!=null && standard!=null){
                     RunfastActivityTarget target1=new RunfastActivityTarget();
                     if(target.getDiscount()==null && target.getDisprice()!=null){
                         //特价
                         target1.setStops(0);
                         target1.setBusinessid(activity.getBusid());
                         target1.setActivityid(activity.getId());
                         target1.setAgentid(activity.getAgentid());
                         target1.setDisprice(target.getDisprice());
                         target1.setStandarid(standard.getId());
                         target1.setGoodsid(standard.getGoodssellid());
                         runfastActivityTargetService.insert(target1);
                     }else if(target.getDiscount()!=null){
                         //折扣
                         Double i=0.00;
                         i=standard.getPrice()*target.getDiscount();
                         target1.setStops(0);
                         target1.setBusinessid(activity.getBusid());
                         target1.setActivityid(activity.getId());
                         target1.setAgentid(activity.getAgentid());
                         if(target.getDisprice()!=null){
                             target1.setDisprice(target.getDisprice());
                         }else{ target1.setDisprice(i);}
                         target1.setDiscount(target.getDiscount());
                         target1.setStandarid(standard.getId());
                         target1.setGoodsid(standard.getGoodssellid());
                         runfastActivityTargetService.insert(target1);
                     }
                 }else{return Result.fail(null,"找不到对应的活动或者规格！");}
             }
         }else{return  Result.fail(null,"传入参数出错！");}
        return Result.ok(null);
     }
     /**单个规格活动删除--恢复*/
     @GetMapping("/deleteStandardActivity")
     public Result deleteStandardActivity(RunfastActivityTarget target){
        if(target!=null && target.getStandarid()!=null && target.getActivityid()!=null){
            RunfastActivityTargetExample  example =new RunfastActivityTargetExample();
            example.createCriteria().andActivityidEqualTo(target.getActivityid()).andStandaridEqualTo(target.getStandarid());
            List<RunfastActivityTarget>   activityTargetList=runfastActivityTargetService.selectByExample(example);
            if(activityTargetList.size()>0){
                 for(RunfastActivityTarget target1:activityTargetList){
                     target1.setDeleted(true);
                     runfastActivityTargetService.updateByPrimaryKeySelective(target1);
                 }
            }
        }else{return Result.fail(null,"传入参数不对！");}
        return Result.ok(null);
     }



     /**活动作废*/
     @GetMapping("/discard")
     public Result discard(RunfastActivity activity){
         if(activity!=null && activity.getId()!=null){
             RunfastActivity activity1 = runfastActivityService.selectByPrimaryKey(activity.getId());
             if(activity1!=null){
                 activity1.setDiscard(true);
                 activity1.setDiscardtime(new Date());
                 runfastActivityService.updateByPrimaryKeySelective(activity1);
             }else{return Result.fail(null,"未找到对应的活动！");}
         }else{return Result.fail(null,"传入参数出错！");}
       return Result.ok(null);
     }

     /**活动删除*/
     @GetMapping("/delete")
     public Result delete(RunfastActivity activity){
         if(activity!=null && activity.getId()!=null){
             RunfastActivity activity1 = runfastActivityService.selectByPrimaryKey(activity.getId());
             if(activity1!=null){
                 activity1.setDeleted(1);
                 runfastActivityService.updateByPrimaryKeySelective(activity1);
             }else{return Result.fail(null,"未找到对应的活动！");}
         }else{return Result.fail(null,"传入参数出错！");}
         return Result.ok(null);
     }
     /**设置为特惠专区活动*/
     @GetMapping("/setToSpecialPriceArea")
     public Result setToSpecialPriceArea(RunfastActivity activity){
        if(activity!=null && activity.getSpecialType()!=null && activity.getId()!=null){
            RunfastActivity activity1 = runfastActivityService.selectByPrimaryKey(activity.getId());
            if(activity1!=null){
                if(activity.getSpecialType()==1){
                    if(activity1.getPtype()==2 || activity1.getPtype()==4){
                        //打折或者特价
                        WaiMaiRunfastAgentbusiness agentbusiness=waiMaiRunfastAgentbusinessService.selectByPrimaryKey(activity1.getAgentid());
                        Map<Object, Object> map1= new HashMap<Object, Object>();
                        map1.put("agentId",agentbusiness.getId());
                        map1.put("specialType",1);
                        map1.put("businessId",activity1.getBusid());
                        if(activity1.getPtype()==1){
                            map1.put("pType",activity1.getPtype());
                        }else if(activity1.getPtype()==5 || activity1.getPtype()==7){
                            map1.put("pTypes","2,4");
                        }
                        List<RunfastActivity> list=runfastActivityService.selectByExampleNew(map1);
                        //Integer  total=runfastActivityService.countByExampleNew(map1);
                        if(list.size()>0){
                            for(RunfastActivity activity2:list){
                                activity2.setSpecialType(0);
                                runfastActivityService.updateByPrimaryKeySelective(activity2);
                            }
                        }
                        activity1.setSpecialType(1);
                        runfastActivityService.updateByPrimaryKeySelective(activity1);
                    }else if(activity1.getPtype()==1 || activity1.getPtype()==5 || activity1.getPtype()==7){
                        //设置为特惠专区活动
                        WaiMaiRunfastAgentbusiness agentbusiness=waiMaiRunfastAgentbusinessService.selectByPrimaryKey(activity1.getAgentid());
                        Map<Object, Object> map1= new HashMap<Object, Object>();
                        map1.put("agentId",agentbusiness.getId());
                        map1.put("specialType",1);
                        if(activity1.getPtype()==1){
                            map1.put("pType",activity1.getPtype());
                        }else if(activity1.getPtype()==5 || activity1.getPtype()==7){
                            map1.put("pTypes","5,7");
                        }
                        List<RunfastActivity> list=runfastActivityService.selectByExampleNew(map1);
                        //Integer  total=runfastActivityService.countByExampleNew(map1);
                        if(list.size()>0){
                            for(RunfastActivity activity2:list){
                                activity2.setSpecialType(0);
                                runfastActivityService.updateByPrimaryKeySelective(activity2);
                            }
                        }
                        activity1.setSpecialType(1);
                        runfastActivityService.updateByPrimaryKeySelective(activity1);
                    }
                }else if(activity.getSpecialType()==0){
                    //设置为非特惠专区活动
                    activity1.setSpecialType(0);
                    runfastActivityService.updateByPrimaryKeySelective(activity1);
                }
            }else{return Result.fail(null,"未找到对应的活动！");}
        }else{return  Result.fail(null,"传入参数出错！");}
        return Result.ok(null);
     }

    /**
     * 优惠专区---活动列表（首页模块，广告模块使用）
     */
   /* @GetMapping("/selectSpecialPriceAreaList")
    public Result selectSpecialPriceAreaList(RunfastActivity activity){
        List<RunfastActivity> list=new ArrayList<RunfastActivity>();
        Integer total =null;
        Map<Object,Object> map=new HashMap<Object, Object>();
        if(StringUtils.isNotBlank(activity.getName())){
            map.put("name",activity.getName());
        }
        if(activity!=null && activity.getSelectNum()!=null&&activity.getAgentid()!=null){
            if(activity.getSelectNum()==1){
                //优惠专区/大额满减活动
                map.put("pType",1);
            }else if(activity.getSelectNum()==2){
                //满配送费活动
                map.put("pTypes","5,7");
            }else if(activity.getSelectNum()==3){
                //特惠优选专区--单品活动
                map.put("pTypes","2,4");
            }
            map.put("agentId",activity.getAgentid());
            map.put("specialType",1);
            list=runfastActivityService.selectByExampleNew(map);
            //total =runfastActivityService.countByExampleNew(map);
        }else{return Result.fail(null,"传入参数不对！");}
       // Map<Object,Object> map1=new HashMap<Object, Object>();
        //map1.put("list",list);
       // map1.put("total",total);
        return Result.ok(null,list);
    }*/
    /**
     * 删除活动---暂时不实现
     */
    /*@PostMapping("/delete")
    @RequiresPermissions("sys:role:delete")
    public R delete(@RequestBody Long[] roleIds){
        sysRoleService.deleteBatch(roleIds);

        return R.ok();
    }*/

    /**
     * 单品活动---保存活动去选商品功能
     * */
   /* @GetMapping("/selectActivityGoods")
    public Result selectActivityGoods(Integer businessId,Integer activityId){
        if(businessId==null){Result.fail(null,"请选择参加单品活动的商家！");}
        List<RunfastGoodsSellType> typeList=null;
        if(businessId!=null){
            RunfastBusiness business=runfastBusinessService.selectByPrimaryKey(businessId);
            if(business !=null){
                RunfastGoodsSellTypeExample example=new RunfastGoodsSellTypeExample();
                example.createCriteria().andBusinessidEqualTo(business.getId());
                typeList=runfastGoodsSellTypeService.selectByExample(example);
            }
            if(typeList.size()>0){
                for(RunfastGoodsSellType type:typeList){
                    RunfastGoodsSellExample goodsSellExample=new RunfastGoodsSellExample();
                    goodsSellExample.createCriteria().andSelltypeidEqualTo(type.getId());
                    goodsSellExample.createCriteria().andBusinessidEqualTo(businessId);
                    List<RunfastGoodsSell> goodsSellList=runfastGoodsSellService.selectByExample(goodsSellExample);
                    runfastGoodsSellService.setStandardList(goodsSellList);
                    Integer goodsSellTotal=runfastGoodsSellService.countByExample(goodsSellExample);
                    type.setGoodsSells(goodsSellList);
                    type.setNum(goodsSellTotal);
                }
            }
        }
        Map<Object,Object> map=new HashMap<Object, Object>();
        map.put("activityId",activityId);
        map.put("typeList",typeList);
        return Result.ok(null,map);
    }*/
    /**
     * 单品活动--商品-活动保存功能
     * */
   /* @PostMapping("/saveActivityGoods")
    public  Result saveActivityGoods(){
        return null;
    }*/

    /**
     * 活动列表带分的页
     */
   /* @GetMapping("/activityList")
    public Result activityList(@PageableDefault Pageable pageable, RunfastActivity t){
        BaseUser admin = SessionContext.getAdmin();
        WaiMaiRunfastAgentaccounts agentAccounts= SessionContext.getCurrentRunfastAgentaccounts();
        RunfastBusinessAccounts accounts = SessionContext.getRunfastBusinessAccounts();
        Map<Object,Object> map=new HashMap<Object, Object>();
        List<RunfastActivity> activityList=new ArrayList<RunfastActivity>();
        RunfastActivityTargetExample targetExample=new RunfastActivityTargetExample();
        if(accounts!=null){
            //商家帐号登录----只能看自己商家的
            targetExample.createCriteria().andBusinessidEqualTo(accounts.getId());
        }else if(agentAccounts!=null){
            //代理商
            targetExample.createCriteria().andAgentidEqualTo(accounts.getAgentid());
        }else if(admin !=null){
            //后台管理员---查看全部的
            if(admin.getAgents().size()>0){
                targetExample.createCriteria().andAgentidIn(admin.getAgents());
            }else{
                 targetExample=null;
            }
        }
        List<RunfastActivityTarget> targetList=runfastActivityTargetService.selectByExampleWithPageable(targetExample,pageable);
        Integer total=runfastActivityTargetService.countByExample(targetExample);
        if(targetList.size()>0){
            for(RunfastActivityTarget target:targetList){
                RunfastActivity activity=new RunfastActivity();
                activity=runfastActivityService.selectByPrimaryKey(target.getActivityid());
                if(activity.getType()==1){
                    RunfastFullLessExample fullLessExample=new RunfastFullLessExample();
                    fullLessExample.createCriteria().andActivityIdEqualTo(activity.getId());
                    List<RunfastFullLess> fullLessList=runfastFullLessService.selectByExample(fullLessExample);
                    activity.setFullLessList(fullLessList);
                }
                activityList.add(activity);
            }
        }
        map.put("activityList",activityList);
        map.put("total",total);
        return Result.ok(null,map);
    }*/

    /**
     * 活动列表
     */
    /*@GetMapping("/select")
    @RequiresPermissions("server:goodsSellType:select")
    public Result select(){
        List<RunfastGoodsSellType> list = runfastGoodsSellTypeService.selectByExample(null);
        return Result.ok(null,list);
    }*/

    /**
     * 修改活动
     */
   /* @PostMapping("/update")
    public Result update(@RequestBody RunfastActivity t){
        BaseUser admin = SessionContext.getAdmin();
        WaiMaiRunfastAgentaccounts accounts= SessionContext.getCurrentRunfastAgentaccounts();
        RunfastBusinessAccounts businessAccounts = SessionContext.getRunfastBusinessAccounts();
        if(t!=null&&t.getId()!=null){
            RunfastActivity old = runfastActivityService.selectByPrimaryKey(t.getId());
            if(old!=null && old.getId()!=null){
                if(admin!=null && admin.getType()==2 && accounts!=null&& accounts.getAgentid()!=null && !accounts.getAgentid().equals(old.getAgentid())){
                    return Result.fail(null,"只能修改自己名下商家的活动！");
                }
                if(admin!=null && admin.getType()==3 && businessAccounts!=null && businessAccounts.getBusinessid()!=null && !businessAccounts.getBusinessid().equals(old.getBusid())){
                    return Result.fail(null,"只能修改自己名下的活动！");
                }





                runfastActivityService.updateByPrimaryKeySelective(t);
            }else{return Result.fail(null,"找不到对应的活动！");}
        }
        return Result.ok(null);
    }*/
}
